package com.xjy.rpc.config.serializer;

import com.alibaba.fastjson.JSON;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * fastJson实现redis序列化
 */
public class FastJsonSerializer implements RedisSerializer {
    @Override
    public byte[] serialize(Object o) throws SerializationException {
        //return new byte[0];
        return JSON.toJSONBytes(o);
    }

    @Override
    public Object deserialize(byte[] bytes) throws SerializationException {
        return JSON.toJSON(bytes);
    }
}
